package UIPackage;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.GregorianCalendar;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import org.dyno.visual.swing.layouts.Constraints;
import org.dyno.visual.swing.layouts.GroupLayout;
import org.dyno.visual.swing.layouts.Leading;

import Sistem.Register;
//VS4E -- DO NOT REMOVE THIS LINE!
public class MusteriEkleGUI extends JFrame {

	private static final long serialVersionUID = 1L;
	private JLabel jLabel0;
	private JLabel jLabel1;
	private JLabel jLabel2;
	private JLabel jLabel3;
	private JLabel jLabel4;
	private JTextField jTextField0;
	private JTextField jTextField1;
	private JTextField jTextField2;
	private JTextField jTextField3;
	private JTextField jTextField5;
	private JLabel jLabel5;
	private JLabel jLabel6;
	private JButton jButton0;
	private Register r;
	private JTextArea jTextArea0;
	private JScrollPane jScrollPane0;
	private JLabel jLabel7;
	private JComboBox jComboBox0;
	private static final String PREFERRED_LOOK_AND_FEEL = "javax.swing.plaf.metal.MetalLookAndFeel";
	public MusteriEkleGUI() {
		initComponents();
	}
	public MusteriEkleGUI(Register r){
		this.r=r;
		initComponents();
		jTextArea0.setText(String.valueOf(r.getMusteriID()));
	}

	private void initComponents() {
		setLayout(new GroupLayout());
		add(getJLabel0(), new Constraints(new Leading(125, 10, 10), new Leading(28, 10, 10)));
		add(getJLabel1(), new Constraints(new Leading(25, 10, 10), new Leading(79, 10, 10)));
		add(getJLabel2(), new Constraints(new Leading(25, 12, 12), new Leading(114, 10, 10)));
		add(getJLabel3(), new Constraints(new Leading(25, 12, 12), new Leading(152, 10, 10)));
		add(getJLabel4(), new Constraints(new Leading(25, 12, 12), new Leading(193, 10, 10)));
		add(getJTextField2(), new Constraints(new Leading(198, 28, 10, 10), new Leading(149, 12, 12)));
		add(getJLabel5(), new Constraints(new Leading(231, 13, 10, 10), new Leading(149, 12, 12)));
		add(getJTextField3(), new Constraints(new Leading(242, 28, 10, 10), new Leading(150, 12, 12)));
		add(getJLabel6(), new Constraints(new Leading(277, 11, 10, 10), new Leading(152, 12, 12)));
		add(getJTextField5(), new Constraints(new Leading(288, 43, 12, 12), new Leading(150, 12, 12)));
		add(getJTextField0(), new Constraints(new Leading(198, 82, 10, 10), new Leading(75, 12, 12)));
		add(getJTextField1(), new Constraints(new Leading(198, 82, 12, 12), new Leading(112, 12, 12)));
		add(getJScrollPane0(), new Constraints(new Leading(199, 80, 12, 12), new Leading(191, 22, 12, 12)));
		add(getJButton0(), new Constraints(new Leading(121, 10, 10), new Leading(279, 10, 10)));
		add(getJLabel7(), new Constraints(new Leading(25, 12, 12), new Leading(228, 10, 10)));
		add(getJComboBox0(), new Constraints(new Leading(198, 82, 12, 12), new Leading(225, 12, 12)));
		setSize(381, 353);
	}
	private JComboBox getJComboBox0() {
		if (jComboBox0 == null) {
			jComboBox0 = new JComboBox();
			jComboBox0.setModel(new DefaultComboBoxModel(new Object[] { "Çocuk", "Ogrenci", "Yetişkin", "Yaşlı" }));
			jComboBox0.setDoubleBuffered(false);
			jComboBox0.setBorder(null);
		}
		return jComboBox0;
	}
	private JLabel getJLabel7() {
		if (jLabel7 == null) {
			jLabel7 = new JLabel();
			jLabel7.setText("Müşteri Tipi");
		}
		return jLabel7;
	}
	private JScrollPane getJScrollPane0() {
		if (jScrollPane0 == null) {
			jScrollPane0 = new JScrollPane();
			jScrollPane0.setViewportView(getJTextArea0());
		}
		return jScrollPane0;
	}
	private JTextArea getJTextArea0() {
		if (jTextArea0 == null) {
			jTextArea0 = new JTextArea();
		}
		return jTextArea0;
	}
	private JButton getJButton0() {
		if (jButton0 == null) {
			jButton0 = new JButton();
			jButton0.setText("Tamam");
			jButton0.addMouseListener(new MouseAdapter() {
	
				public void mouseClicked(MouseEvent event) {
					jButton0MouseMouseClicked(event);
				}
			});
		}
		return jButton0;
	}
	private JLabel getJLabel6() {
		if (jLabel6 == null) {
			jLabel6 = new JLabel();
			jLabel6.setText("/");
		}
		return jLabel6;
	}

	private JLabel getJLabel5() {
		if (jLabel5 == null) {
			jLabel5 = new JLabel();
			jLabel5.setText("/");
		}
		return jLabel5;
	}

	private JTextField getJTextField5() {
		if (jTextField5 == null) {
			jTextField5 = new JTextField();
		}
		return jTextField5;
	}
	private JTextField getJTextField3() {
		if (jTextField3 == null) {
			jTextField3 = new JTextField();
		}
		return jTextField3;
	}
	private JTextField getJTextField2() {
		if (jTextField2 == null) {
			jTextField2 = new JTextField();
		}
		return jTextField2;
	}
	private JTextField getJTextField1() {
		if (jTextField1 == null) {
			jTextField1 = new JTextField();
		}
		return jTextField1;
	}
	private JTextField getJTextField0() {
		if (jTextField0 == null) {
			jTextField0 = new JTextField();
		}
		return jTextField0;
	}
	private JLabel getJLabel4() {
		if (jLabel4 == null) {
			jLabel4 = new JLabel();
			jLabel4.setText("MusteriID");
		}
		return jLabel4;
	}
	private JLabel getJLabel3() {
		if (jLabel3 == null) {
			jLabel3 = new JLabel();
			jLabel3.setText("Doğum Tarihi");
		}
		return jLabel3;
	}
	private JLabel getJLabel2() {
		if (jLabel2 == null) {
			jLabel2 = new JLabel();
			jLabel2.setText("Soyadı");
		}
		return jLabel2;
	}
	private JLabel getJLabel1() {
		if (jLabel1 == null) {
			jLabel1 = new JLabel();
			jLabel1.setText("Adı");
		}
		return jLabel1;
	}
	private JLabel getJLabel0() {
		if (jLabel0 == null) {
			jLabel0 = new JLabel();
			jLabel0.setText("Musteri Bilgi Formu");
		}
		return jLabel0;
	}

	private static void installLnF() {
		try {
			String lnfClassname = PREFERRED_LOOK_AND_FEEL;
			if (lnfClassname == null)
				lnfClassname = UIManager.getCrossPlatformLookAndFeelClassName();
			UIManager.setLookAndFeel(lnfClassname);
		} catch (Exception e) {
			System.err.println("Cannot install " + PREFERRED_LOOK_AND_FEEL
					+ " on this platform:" + e.getMessage());
		}
	}

	/**
	 * Main entry of the class.
	 * Note: This class is only created so that you can easily preview the result at runtime.
	 * It is not expected to be managed by the designer.
	 * You can modify it as you like.
	 */
	public static void main(String[] args) {
		installLnF();
		SwingUtilities.invokeLater(new Runnable() {
			@Override
			public void run() {
				MusteriEkleGUI frame = new MusteriEkleGUI();
				frame.setDefaultCloseOperation(MusteriEkleGUI.EXIT_ON_CLOSE);
				frame.setTitle("MusteriEkle");
				frame.getContentPane().setPreferredSize(frame.getSize());
				frame.pack();
				frame.setLocationRelativeTo(null);
				frame.setVisible(true);
			}
		});
	}
	private void jButton0MouseMouseClicked(MouseEvent event) {
		String adi= jTextField0.getText();
		String soyadi=jTextField1.getText();
		int musteriID=Integer.parseInt(jTextArea0.getText());
		GregorianCalendar dogumTarihi=new GregorianCalendar(Integer.parseInt(jTextField5.getText()), Integer.parseInt(jTextField3.getText()), Integer.parseInt(jTextField2.getText()));
		r.musteriBilgiGir(adi, soyadi, dogumTarihi,musteriID, jComboBox0.getSelectedIndex());
		MusteriOnayGUI form = new MusteriOnayGUI(r);
		this.hide();
		form.show();
		
	}

}
